﻿@model Infinity.BusinessLayer.grouptypeViewModel

@{
    ViewBag.Title = "editegrouptype";
    Layout = "~/Areas/Managerial/Views/Shared/_AdminLayout.cshtml";
}
<span style="color:red">
    @Html.ValidationSummary()
</span>
<section class="course-form">

    @using (Html.BeginForm("Updategrouptype", "GroupType"))
    {
        @Html.AntiForgeryToken()
        @Html.ValidationSummary(true)

        <h2> <strong>Edit group type</strong></h2>



        <span class="input input--jiro">
            <label class="" for="input-10" style="color:gray">
                <span class="input__label-content input__label-content--jiro">
                    &nbsp;&nbsp; @Html.HiddenFor(model => model.GroupTypeID)
                    Group type ID
                    &nbsp;&nbsp;&nbsp;
                    @Model.GroupTypeID
                </span>
            </label>
        </span>
        <br />
        <span class="input input--jiro">
            <input class="input__field input__field--jiro" type="text" value="@Model.type" name="type" id="type" />
            <label class="input__label input__label--jiro " for="input-10">
                <span class="input__label-content input__label-content--jiro">
                    Type Name
                    @*<span class="star">@Html.ValidationMessageFor(model => model.type)</span>*@
                </span>
            </label>
        </span>

        <div>
            <table>
                <tr>
                    <td>
                        <button class="send fromedite Deletegrouptype" value="@Model.GroupTypeID"> Delete</button>
                    </td>
                    <td> &nbsp;&nbsp; @Html.ActionLink("Back to List", "Index", null, new { @class = "send" })</td>
                    <td> &nbsp;&nbsp;  @Html.ActionLink("Create new Group Type", "Newgrouptype", null, new { @class = "send" })</td>
                    <td> &nbsp;&nbsp;  <input type="submit" class="send" value="Save" /></td>
                </tr>
            </table>
        </div>
    }

</section>
<div style="height:200px"></div>


<script src="~/Content/js/jquery-1.11.2.min.js"></script>
<script>
    //Delete
    $(document).ready(function () {

        $(".Deletegrouptype").click(function (a) {

            var caller = $(this);
            var id = $(this).val();
            var x = $(this).hasClass('fromedite');

            if (confirm("Are you sure you want to delete")) {
                $.ajax({
                    type: "POST",
                    url: "/Managerial/GroupType/Deletegrouptype",
                    data: { ID: id },
                    success: function (list) {

                        if (x == true) {
                            location.href = '/Managerial/GroupType/Index';
                        }
                        else {
                            $('#grouptypeContainer').html(list);
                            alert("deleted Successfully");
                        }

                    },
                    error: function () {
                        alert("can't Delet it");
                    }
                });
            }
        })
    })

</script>
